<template>
  <a @click="dialog = true">
    <span>{{ getState(record.approve) }}</span>
    <!-- <slot name="default"></slot> -->
    <a-modal v-model="dialog" title="项目审核" @ok="submit">
      <h3>请设置批准</h3>
      <a-form-model :form="form">
        <a-radio-group prop="approval" v-model="form.approve">
          <a-radio :value="2">批准</a-radio>
          <a-radio :value="3">拒绝</a-radio>
        </a-radio-group>
        <p style="margin-top:15px" v-if="form.approve == 3">
          原因：
          <a-input style="width:30%" v-model="form.reason" />
        </p>
      </a-form-model>
    </a-modal>
  </a>
</template>
<script>
import { LoanState } from '@/dict'
import { moneyApprove } from '@/api/common'
export default {
  name: 'moneyApprove',
  props: ['record'],
  data: () => ({
    dialog: false,
    form: {
      approve: 2,
      reason: ''
    }
  }),
  methods: {
    getState(v) {
      return LoanState.find(el => el.value == v)?.text || '待审批'
    },
    async submit() {
      await moneyApprove(this.record.id, this.form)
      this.dialog = false
      this.$emit('update')
    }
  }
}
</script>
<style lang="scss" scoped></style>
